import re


class PaperParse(object):
    novel = []

    def getcontent(self):
        return self.novel

    def getcatalogue(self):
        catalogue=[]
        for i in self.novel:
            if "Chapter" in i:
                catalogue.append(i)
        return catalogue


    def __init__(self,s):
        self.novel = s
    #初始化解析
    def parseall(self):
        #去除空行
        for i in self.novel:
            if i == '\n':
                self.novel.remove('\n')
        #去除文字中的换行
        for i in range(0,len(self.novel)):
            self.novel[i] = self.novel[i].replace('\n', '').replace('\r', '')


    #方括号解析
    def second(self):
        for i in range(0,len(self.novel)):
            result = re.sub(u"\\[.*?]", "", self.novel[i].encode('utf-8').decode())
            self.novel[i] = result
